#pragma once;
#include <ostream>
#include <string>
#include "ObjectIterator.h"

class Object
{
public:
	typedef ObjectInnerIterator inner_iterator;
	typedef ObjectOuterIterator outer_iterator;
	friend ObjPtrBase;

	Object(const std::string& name = "") :
		name(name),
		innerRefs(0),
		outerRefs(0)
	{}
	const std::string& getName() const
	{
		return name;
	}
	inner_iterator inner_begin() const;
	inner_iterator inner_end() const;
	outer_iterator outer_begin() const;
	outer_iterator outer_end() const;
	virtual ~Object();
private:
	void addInnerRef(ObjPtrBase* ptr);
	void addOuterRef(ObjPtrBase* ptr);
	void removeOuterRef(ObjPtrBase* ptr);

	std::string name;
	ObjPtrBase* innerRefs;		// linked list
	ObjPtrBase* outerRefs;		// linked list
};


////////for debugging
void printObjectInfo(std::ostream& out, const Object* object);
void printInnerRefs(std::ostream& out, const Object* object);
void printOuterRefs(std::ostream& out, const Object* object);
